home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / lollipop / output.tex < prev    next >
Text File  |  1993-01-28  |  25KB  |  722 lines

  1. % Output.tex copyright 1992/3 Victor Eijkhout
  2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3. %%%%%%%%%%%%%%%%% O U T P U T %%%%%%%%%%%%%%%
  4. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  5.  
  6. \@GenericConstruct{PageGrid}
  7.  
  8. \newif\if@pagegrid@installed
  9. \ifini{\next@paragraph
  10.    {\if@pagegrid@installed \else 
  11.         \Wmessage{No page grid installed}\fi
  12.    }}
  13. \NewTrace:out
  14. \add@PageGrid@default{\text@constructno}
  15. \add@PageGrid@default{\has@marksyes}
  16.  
  17. \newtoks\user@overrides
  18. \def\add@user@override#1{\append@to@list{user@overrides}{#1}}
  19.  
  20. \newif\if@nubalanceren
  21. \newinsert\botins
  22.  
  23. %%%% Page counting
  24. %
  25. % \count0 is the paper counter: 
  26. %     is increased for every \shipout in the output routine
  27. % \count1 is the page counter:
  28. %     you can do with it whatever you like.
  29.  
  30. % This appears to the users as if \NewCounter:Page had been done.
  31. % We do it by hand because the number has to be 1.
  32. %
  33. \countdef\sheet@counter=0
  34. \csarg\countdef{\counter@name{Page}}=1 
  35. \edef\PageValue{\counter@@name{Page}}
  36. \CounterRepresentation:Page=1
  37. \newtoks\Page@RL %trudge trudge!
  38. \SetCounter:Page=1
  39.  
  40. %%%% Tests
  41. %
  42. \DefineTest:IsRightPage
  43. \DefineTest:IsLeftPage
  44. \DefineTest:IsFirstPage
  45. \DefineTest:IsLastPage
  46. \DefineTest:FlushBottom
  47.  
  48. %% anonieme cs'en zijn in gebruik bij opbouw en gebruik %%
  49. % \tempdima : / klad; gebruikt voor hoofdmeting; daarna in \text@column
  50. % \tempdimc : / klad; gebruikt voor voetmeting
  51. % \cs@a : in gebruik door \haalitems
  52.  
  53. \def\slotpenalty{-10001}
  54.  
  55. \def\@pseudoif#1#2{\tempcounta\escapechar \noesc
  56.     \edef\cs@e{\let\CSname{if@\string#1}\CSname{if\string#2}}\cs@e
  57.     \escapechar\tempcounta}
  58. \@pseudoif\IsFirstPage\true \@pseudoif\IsLastPage\true
  59. \@pseudoif\IsRightPage\true
  60. \@pseudoif\IsLeftPage\false
  61.  
  62. \def\leftright@setup
  63.    {\csarg\ifodd{\counter@name{Page}}\relax 
  64.                 \IsRightPage:yes \IsLeftPage:no
  65.           \else \IsRightPage:no  \IsLeftPage:yes
  66.           \fi}
  67. \def\firstpage@setup{\def\cs@a{yes}
  68.     \edef\cs@b{\xp\get@placed\xp{\firstmark}{first@page}}
  69.     \ifx\cs@a\cs@b \IsFirstPage:yes \else \IsFirstPage:no \fi}
  70. \def\lastpage@setup
  71.     {\ifnum\outputpenalty=\slotpenalty\relax 
  72.         \Tmessage[out]{Last page}\IsLastPage:yes
  73.      \else \IsLastPage:no
  74.      \fi}
  75. \def\output@setup{\let\par\@par
  76.     \parindent\z@ \leftskip\z@ \rightskip\z@ \lineskip\z@
  77.     \default@everypar \MainFont
  78.     \leftright@setup    \firstpage@setup    \lastpage@setup
  79.     \@colnum\@ne \output@set@page@width
  80.     \Tmessage[out]{Incoming text: (\the\ht\@cclv+\the\dp\@cclv) x
  81.                    \the\wd\@cclv}
  82.     }
  83.  
  84. %%%%%%%%%%%%%%%% Head, Foot, Body
  85. %
  86. % Separate boxes are allocated for the page
  87. % head, body, and foot.
  88. % Head and foot contain static material, the
  89. % body contains the text. The body can be empty.
  90. %
  91. \newbox\page@head@box \newtoks\page@head@toks
  92. \page@head@toks{}
  93. \add@PageGrid@default
  94.    {\page@head@toks={\setbox\page@head@box=\vbox\bgroup}}
  95. \newdimen\head@height
  96. \def\measure@head{\head@height=\ht\page@head@box
  97.     \advance\head@height\dp\page@head@box
  98.     \Tmessage[out]{Head measurement: \the\head@height}}
  99.  
  100. \newbox\page@foot@box \newtoks\page@foot@toks 
  101. \page@foot@toks{}
  102. \add@PageGrid@default{\page@foot@toks=
  103.               {\setbox\page@foot@box=\vbox\bgroup}}
  104. \newdimen\foot@height
  105. \def\measure@foot{\foot@height=\ht\page@foot@box
  106.     \advance\foot@height\dp\page@foot@box
  107.     \Tmessage[out]{Foot measurement: \the\foot@height}}
  108.  
  109. \def\goal@height@trace
  110.    {\tempdimb\text@height
  111.     \multiply\tempdimb\ifnum\user@n@cols=\m@ne\n@cols\else\user@n@cols\fi
  112.     \Tmessage[out]{Aim for  text height: \the\text@height\@space
  113.     \ifnum\user@n@cols>\m@ne (\the\user@n@cols\@space columns;
  114.                 total height: \the\tempdimb)
  115.     \else\ifnum\n@cols>\@ne (\the\n@cols\@space columns;
  116.                 total height: \the\tempdimb)
  117.     \fi\fi}}
  118.  
  119. \def\report@body@measurement{
  120.     \Tmessage[out]{Body measurement:
  121.         (\the\ht\page@body@box+\the\dp\page@body@box) 
  122.         x\the\wd\page@body@box}
  123.     \ifvoid\topins\else
  124.         \Tmessage[out]{Top inserts: \the\ht\topins+\the\dp\topins}\fi
  125.     \ifvoid\botins\else
  126.         \Tmessage[out]{Foot inserts: \the\ht\footins+\the\dp\footins}\fi
  127.     }
  128.  
  129. \newbox\page@body@box \newtoks\page@body@toks
  130. \page@body@toks{}
  131. \add@PageGrid@default
  132.    {\page@body@toks={\setbox\page@body@box=\vbox\bgroup}}
  133.  
  134. \def\finish@part@routines
  135.    {\append@to@list{page@head@toks}{\egroup\measure@head}
  136.     \append@to@list{page@foot@toks}{\egroup\measure@foot}
  137.     \append@to@list{page@body@toks}{\egroup}}
  138.  
  139. \newbox\WholePage
  140. \def\make@page{
  141.     \setbox\WholePage=\vbox 
  142.        {\box\page@head@box
  143.             \ifabut@head\nointerlineskip\fi
  144.             \ifabut@foot\tempdima\dp\page@body@box\fi
  145.         \box\page@body@box 
  146.             \ifabut@foot\ifvoid\page@foot@box\else
  147.                  \kern-\tempdima\relax\nointerlineskip\fi\fi
  148.         \box\page@foot@box}%\showbox\WholePage
  149.     }
  150.  
  151. % \vsize has two possibilities:
  152. % 1/ it is calculated dynamically by subtracting
  153. % body and foot height from the total page height.
  154. % If \vsize is different from \ht255, the page
  155. % is thrown back.
  156. % 2/ it is set and the page has whatever size results.
  157. %
  158. \newif\iftext@fits
  159. \def\see@if@text@fits
  160.    {{\multiply\text@height\n@cols 
  161.      \tempdima\text@height
  162.      \advance\tempdima-\vsize
  163.      \ifdim\tempdima<\z@ \tempdima=-\tempdima \fi
  164.      \ifdim\tempdima<.1pt\relax
  165.            \global\text@fitsyes
  166.            \Tmessage[out]{Page accepted.}
  167.      \else \global\text@fitsno
  168.            \Tmessage[out]{Text does not fit. (vsize=\the\vsize)}
  169.            \global\vsize=\text@height
  170.      \fi}}
  171.  
  172. % Multicolumn stuff
  173. % every PageGrid macro installs \n@cols, but the user
  174. % can specify a different number with \NumberOfColumns:x
  175. % This sets \user@n@cols which is usually -1
  176. %
  177. \newcount\n@cols \n@cols\@ne
  178. \newcount\@colnum
  179. \newcount\user@n@cols \user@n@cols\m@ne
  180. \Distance:GutterWidth=1cm
  181. \def\NumberOfColumns:#1
  182.    {\user@n@cols=\w@w{#1}\relax
  183.     \Tmessage[out]{Switch to \the\user@n@cols\@space columns}
  184.     \hsize\page@width 
  185.     \tempdima\GutterWidth \multiply\tempdima\user@n@cols
  186.     \advance\tempdima-\GutterWidth
  187.     \advance\hsize-\tempdima \divide\hsize\user@n@cols
  188.     \Tmessage[out]{New hsize: \the\hsize}}
  189. \add@user@override{\ifnum\user@n@cols=\m@ne\else
  190.     \csarg\let{\output@routine @body}\trivial@body
  191.     \n@cols\user@n@cols
  192.     \Tmessage[out]{User override: \the\n@cols\@space columns.}%
  193.     \fi}
  194.  
  195. \def\trivial@body{\Tmessage[out]{Trivial multicolumn (\the\n@cols) setup}
  196.     \@colnum\@ne \splittopskip\topskip
  197.     \setbox\page@body@box\hbox{\text@column}
  198.     \@colnum\tw@
  199.     \ifnum\n@cols>\@ne 
  200.         \loop \setbox\page@body@box\hbox{\unhbox\page@body@box
  201.               \kern\GutterWidth \text@column}
  202.               \advance\@colnum\@ne
  203.               \ifnum\@colnum>\n@cols\else\repeat
  204.     \fi}
  205. \def\real@text@column{\begingroup\vbadness\@M
  206.     \setbox\z@
  207.     \ifnum\n@cols=\@ne
  208.         \vbox to \vsize{\boxmaxdepth\maxdepth
  209.                  \ifvoid\topins\else\unvbox\topins \fi
  210.                  \unvbox\@cclv
  211.                  \ifvoid\footins\else\unvbox\footins \fi}%
  212.         \Tmessage[out]{Column: \the\ht\z@+\the\dp\z@}%
  213.     \else
  214.         \vsplit\@cclv to \text@height
  215.         \Tmessage[out]{Column \the\@colnum: \the\ht\z@+\the\dp\z@}%
  216.     \fi \ifnum\badness=\@M\Wmessage{Underfull textcolumn}\fi
  217.     \box\z@ \endgroup}
  218.  
  219. \def\CurrentShipout{\shipout\box\WholePage}
  220. \let\OriginalShipout\CurrentShipout 
  221. \newif\ifCountSheets \CountSheetsyes
  222. \def\finish@off@page{\Tmessage[out]{Whole page:
  223.                         \the\ht\WholePage+\the\dp\WholePage}
  224.     {\def\protect{\noexpand\protect\noexpand}
  225.      \def\cprotect{\expandafter\string}
  226.      \normalesc
  227.      \ifsink@pages 
  228.        \message{Page sunk [\the\sheet@counter.\csarg\the
  229.                                      {\counter@name{Page}}]}
  230.        \deadcycles\z@
  231.      \else \CurrentShipout
  232.            \ifCountSheets\global\advance\sheet@counter\@ne\fi
  233.      \fi
  234.      }
  235.     \global\step@counter{Page}
  236.     }  
  237. \def\shipout@and@unbox@remainder{
  238.     \iftext@fits \make@page \finish@off@page \fi
  239.     \ifvoid\@cclv \Tmessage[out]{Shipped out whole page}
  240.     \else \Tmessage[out]{Part of page not shipped: \the\ht\@cclv} 
  241.           \unvbox\@cclv 
  242.           \ifnum\outputpenalty=\@M\else\penalty\outputpenalty\fi
  243.     \fi
  244.     \iftext@fits \ifother@grid\install@next@page@grid
  245.                  \else\Tmessage[out]{Same grid once again.}\fi 
  246.     \fi}
  247.  
  248. \newif\ifsink@pages
  249. \sink@pagesno
  250. \let\NoPages\sink@pagesyes \let\PagesOut\sink@pagesno
  251.  
  252. % this is a mess. clear up please.
  253. \newtoks\page@options
  254. \def\options@to@pagepart
  255.    {\append@toks@cs@to@list{page@\page@part @toks}\page@options
  256.               \page@options={}}
  257. \add@PageGrid@default{\csarg\newtoks{\@name @routine}
  258.     \def\@current@options@list{page@options}
  259.     \def\page@part{head}\page@options{}
  260.     }
  261.  
  262. \def\install@output@routine#1{{\globaldefs\@ne
  263.     \output=\xp{\csname#1@routine\endcsname}%
  264.     \def\output@routine{#1}%
  265.     \Tmessage[out]{Install output: #1 ---}%
  266.     \@pagegrid@installedyes
  267.     \csname#1@install@parameters\endcsname
  268.     }}
  269.  
  270. \newdimen\text@height
  271.  
  272. % During the load of this file we build up a list of
  273. % defaults and test. These are then turned into PageGrid@default
  274. % at the end of this file.
  275. \newtoks\otr@settings \newtoks\otr@conditions
  276. \def\add@otr@setting#1{\append@to@list{otr@settings}{#1}}
  277. \def\del@otr@setting#1{\del@tok@from@list{otr@settings}#1}
  278. \def\add@otr@condition#1{\append@to@list{otr@conditions}{#1}}
  279. \def\set@otr@stuff{\def\cs@e##1{
  280.     \edef\cs@f{\nxp\adds@PageGrid@default{\global##1={\the##1}}}
  281.     \cs@f}
  282.   \cs@e\otr@settings \cs@e\otr@conditions}
  283. %\showthe\otr@settings \showthe\otr@conditions
  284. %\showthe\PageGrid@defaults}
  285.        
  286. \def\@DefinePageGrid{\options@to@pagepart \finish@part@routines
  287.     \csarg\edef{\@name @install@parameters}{%
  288.           \vsize\the\height@toks\relax \set@topskip
  289.           \multiply\vsize
  290.             \nxp\ifnum\user@n@cols>\@ne\user@n@cols\relax
  291.             \nxp\else\the\n@cols\relax\nxp\fi
  292.           \hsize\the\width@toks\relax
  293.           \def\CSname{\@name @page@width}%
  294.                  {\the\width@toks\relax}%
  295.           \nxp\Tmessage[out]{Initial hsize: \nxp\the\hsize}%
  296.           \ifwidth@of@text 
  297.           \else \nxp\hsize@from@page@width
  298.                 \ifnum\the\n@cols>1 
  299.                     \divide\hsize\the\n@cols\relax\fi
  300.           \fi
  301.           \nxp\Tmessage[out]{Installed hsize: \nxp\the\hsize}%
  302.           }
  303.     \csarg\edef{\@name @otr@parameters}{%
  304.           \the\otr@settings
  305.           \xp\@empty\the\otr@conditions
  306.           \CSname{height@of@text\ifheight@of@text yes\else no\fi}%
  307.           \text@height\the\height@toks\relax
  308.           \CSname{width@of@text\ifwidth@of@text yes\else no\fi}%         
  309.           \n@cols\the\n@cols\relax}
  310.     \csarg\edef{\@name @head@foot}{\the\page@head@toks 
  311.           \the\page@foot@toks
  312.           \ifheight@of@text\else
  313.           \advance\text@height-\head@height 
  314.           \advance\text@height-\foot@height
  315.           \fi}
  316.     \csarg\edef{\@command @body}{\the\page@body@toks}
  317.     \csarg\edef{\@command}{%
  318.           \nxp\EjectPage
  319.           \nxp\install@output@routine{\@name}%
  320.           %\global\hsize= \ifseen@text \CSname{\@name @text@width}%
  321.           %           \else \CSname{\next@page@grid @text@width}%
  322.           %           \fi
  323.           \outer@start@commands \after@indent
  324.           }
  325.   \csarg\edef{\@name @routine}{
  326.     \nxp\Tmessage[out]{======== Output routine: \@name\@space ==========}
  327.     \nxp\output@setup 
  328.     \CSname{\@name @otr@parameters}
  329.     \nxp\the\user@overrides
  330.     \CSname{\@name @head@foot}
  331.     \nxp\goal@height@trace
  332.     \ifnum\n@cols=\z@ %% no text, trivial case.
  333.       \setbox\page@body@box\voidb@x 
  334.       \nxp\text@fitsyes
  335.     \else \nxp\ifragged@bottom\nxp\text@fitsyes
  336.       \nxp\else\nxp\see@if@text@fits\nxp\fi
  337.       \nxp\iftext@fits
  338.           \let\nxp\text@column\nxp\real@text@column
  339.           \tempcounta\hbadness\hbadness\@M\CSname{\@name @body}
  340.           \nxp\ifnum\badness>\tempcounta
  341.             \nxp\Wmessage{Underfull page body}\nxp\fi
  342.           \hbadness\tempcounta\nxp\report@body@measurement
  343.           \nxp\fi
  344.     \fi
  345.     \nxp\shipout@and@unbox@remainder
  346.     \nxp\Tmessage[out]{==========}%
  347.     }
  348.   \xp\install@output@routine\xp{\@name}
  349.   }
  350.  
  351. % not operative yet.
  352. \new@dimen{user@page@height}{\m@ne sp}
  353. \new@dimen{user@text@height}{\m@ne sp}
  354. \def\Height:#1=#2
  355.    {\switch {\if\EqualString{#1}}
  356.     {Page} {\user@page@height\w@w{#2}}
  357.     {Text} {\user@text@height\w@w{#2}}
  358.     {default} {\Wmessage{Unknown option: `Height:#1=#2'}}
  359.     \endswitch}
  360.  
  361. %-- height of page/text
  362. %
  363. % the \ifheight@of@text conditional is also used
  364. % during run time.
  365. %
  366. \newif\ifheight@of@text
  367. \newtoks\height@toks \newdimen\page@height
  368. \add@PageGrid@default{\height@of@textyes\height@toks{20cm}}
  369. \add@PageGrid@default{\let\text@lines\relax}
  370. \@PageGridOption{height}{
  371.     \switch {\if\EqualString{#1}}
  372.         {page}  {\height@of@textno}
  373.         {text}  {\height@of@textyes}
  374.         {lines} {\height@of@textyes
  375.               \edef\cs@e{\def\nxp\text@lines{\@w@w{#2}}}\cs@e}
  376.         {default} {\Wmessage{Strange modifier: `height:#1=#2'}}
  377.     \endswitch
  378.     \edef\cs@e{\nxp\height@toks={\@w@w{#2}}}\cs@e
  379.     }
  380. % Make sure that the \Height command is not used!
  381. \@PageGridNOOP{Height}
  382.  
  383. %%%%
  384. %
  385. % Width handling
  386. %
  387. \newif\ifwidth@of@text
  388. \newtoks\width@toks \newdimen\page@width
  389. \@PageGridOption{width}{
  390.     \switch {\if\EqualString{#1}}
  391.         {page} {\width@of@textno}
  392.         {text} {\width@of@textyes}
  393.         {default} {\Wmessage{Strange modifier: `width:#1=#2'}}
  394.     \endswitch
  395.     \edef\cs@e{\nxp\width@toks={\@w@w{#2}}}\cs@e
  396.     }
  397.  
  398. % Make sure that the \Width command is not used!
  399. \@PageGridNOOP{Width}
  400.  
  401. % At installation of the output routine, calculate the hsize
  402. % if the page width is given.
  403. %
  404. \def\hsize@from@page@width
  405.    {\def\text@column{\hskip\z@\relax}%
  406.     \everyhbox{}\everyvbox{}%
  407.     \let\maybe@to@page@width\relax
  408.     \the\page@body@toks 
  409. %\ifdim\wd\page@body@box>0pt \showthe\page@body@toks \fi
  410.     \Tmessage[out]{Width page body minus text: \the\wd\page@body@box}%
  411.     \global\advance\hsize-\wd\page@body@box}
  412.  
  413. % At the start of the output routine, calculate the page width
  414. % from the hsize (which may have been tinkered with), or set to
  415. % routine-specific page width (which may also have been changed).
  416. %
  417. \def\output@set@page@width
  418.    {\ifwidth@of@text
  419.         \edef\text@column{\hskip\the\wd\@cclv\relax\hskip\z@\relax}%
  420.         \let\maybe@to@page@width\relax
  421.         \csn\output@routine @body\ecs
  422.         \page@width\wd\page@body@box
  423.         \Tmessage[out]{Deduced page width: \the\page@width}
  424.     \else \def\maybe@to@page@width{ to \page@width}
  425.         \page@width\csn\output@routine @page@width\ecs\relax
  426.     \fi}
  427.  
  428. %%%% Topskip
  429. % initially the outer topskip is picked up, unless
  430. % the option 'topskip' is given.
  431. %
  432. \add@PageGrid@default
  433.    {\edef\set@topskip
  434.       {\topskip\the\topskip\relax\splittopskip\topskip}}
  435. \@PageGridOption{topskip}{
  436.     \edef\cs@e
  437.        {\def\nxp\set@topskip{\topskip\@w@w{#1}\relax
  438.                      \splittopskip\topskip}}
  439.     \cs@e
  440.     }
  441. % ragged bottom the way it's done in plain TeX.
  442. \newif\ifragged@bottom
  443. \add@otr@setting{\ragged@bottomno}
  444. \@PageGridOption{raggedbottom}{
  445.     \del@otr@setting{\ragged@bottomno}
  446.     \add@otr@setting{\ragged@bottomyes}
  447.     \if\EmptyList{#1}\@add@toks{\var@topskip{60pt}}
  448.     \else\edef\cs@e{\nxp\@add@toks{\nxp\var@topskip{\@w@w{#1}}}}
  449.          \cs@e
  450.     \fi}
  451. \def\var@topskip#1{\tempdima\topskip\tempskipa\z@ plus #1\relax
  452.     \topskip\tempdima \advance\topskip\tempskipa
  453.     \splittopskip\topskip}
  454.  
  455. %-- textband
  456. \newif\ifin@textband \add@PageGrid@default{\in@textbandno}
  457. \@PageGridOption{textband}{
  458.     \switch {\if\EqualString{#1}}
  459.         {start} {\start@textband}
  460.         {stop}  {\stop@textband}
  461.         {default} {\Wmessage{Strange modifier `textband:#1'}}
  462.     \endswitch}
  463. \newdimen\text@width
  464. \def\start@textband
  465.    {\options@to@pagepart 
  466.     \b@group[textband]\@hmodeyes\in@textbandyes
  467.     \@add@toks{\hbox \maybe@to@page@width\bgroup}
  468.     }
  469. \def\stop@textband
  470.    {\@add@toks{\egroup} \e@group[textband]
  471.     \ifseen@text \before@textno
  472.              \def\page@part{body} \options@to@pagepart
  473.              \def\page@part{foot} 
  474.     \fi}
  475.  
  476. %-- band
  477. \newif\ifabut@foot \newif\ifabut@head
  478. \add@otr@setting{\abut@footno \abut@headno}
  479. \@PageGridOption{band}{
  480.   \switch {\if\EqualString{#1}}
  481.     {start} {\@add@toks{\hbox to \page@width\bgroup}
  482.               \b@group[band]\@hmodeyes
  483.               \def\block@closing{\@add@toks{\hfil\egroup}
  484.                   \e@group[band]}}
  485.     {invisible} {\@add@toks{\setbox\tempboxa
  486.                                 \hbox to \page@width\bgroup}
  487.               \b@group[band]\@hmodeyes
  488.               \def\block@closing{\@add@toks{\hfil\egroup}
  489.                   \ifbefore@text
  490.                       \@add@toks{\vtop to\z@{\kern\z@\box\tempboxa\vss}
  491.                                       \nointerlineskip}
  492.                       \del@otr@setting{\abut@headno}
  493.                       \add@otr@setting{\abut@headyes}
  494.                       %\global\abut@headyes
  495.                   \else  \@add@toks{\nointerlineskip
  496.                                       \vbox to\z@{\vss\box\tempboxa}}
  497.                       \del@otr@setting{\abut@footno}
  498.                       \add@otr@setting{\abut@footyes}
  499.                       %\global\abut@footyes
  500.                   \fi\e@group[band]}}
  501.     {stop}  {\block@closing}
  502.     {default} {\Wmessage{Strange modifier `band:#1'}}
  503.   \endswitch}
  504.  
  505.  
  506. %-- next page grid
  507. \newif\ifother@grid
  508. \add@PageGrid@default{\other@gridno}
  509. \add@otr@setting{\other@gridno}
  510. \add@otr@condition{\ifother@grid
  511.     \def\nxp\install@next@page@grid
  512.        {\nxp\install@output@routine{\next@page@grid}}%
  513.   \fi}
  514. \@PageGridOption{NextPageGrid}{\other@gridyes
  515.     \del@otr@setting{\other@gridno}
  516.     \add@otr@setting{\other@gridyes}
  517.     \def\next@page@grid{#1}
  518.     }
  519.  
  520. %-- text
  521. \add@PageGrid@default{\n@cols\z@}
  522. \newif\ifbefore@text 
  523. \newif\ifseen@text %this one is also used by 'external'
  524. \add@PageGrid@default{\before@textyes \seen@textno}
  525. \@PageGridOption{text}{\global\seen@textyes
  526.     \ifin@textband\else\Emessage{'text' has to be in 'textband'}\fi
  527.     \global\advance\n@cols\@ne
  528.     \@add@toks{\text@column}}
  529.  
  530. %%%%%%%%%%%%%%%%%%%%%%% user commands
  531.  
  532. \def\leegbladinvoegen{\@g@stapteller{Page}}
  533. \def\EjectPage{\vfil\eject}
  534. \def\ToRecto{\csarg\ifodd{\counter@name{Page}}\else\step@counter{Page}\fi}
  535. \def\ToVerso{\csarg\ifodd{\counter@name{Page}}\step@counter{Page}\fi}
  536.  
  537. % less useful user command (mostly for formatting the manual :-)
  538. %
  539. \newbox\saved@page@box \newdimen\saved@hsize \newcount\saved@pageno
  540. \newtoks\saved@mark@items
  541. \def\SuspendOutput{\xdef\saved@output@routine{\output@routine}%
  542.     \let\saved@shipout\CurrentShipout
  543.     \global\saved@hsize\hsize \global\saved@mark@items\mark@items
  544.     \global\saved@pageno\cs@counter@name{Page}%
  545.     \output{\global\setbox\saved@page@box\box\@cclv
  546.             \Tmessage[out]{Suspend output @\the\saved@pageno; 
  547.                saved (\the\ht\saved@page@box+\the\dp\saved@page@box)
  548.                x \the\wd\saved@page@box}%
  549.             \global\output{\Emessage{You should not call output now!}%
  550.                            \OriginalShipout\box\@cclv}}%
  551.     \eject
  552.     }
  553. \def\ResumeOutput
  554.    {\xp\install@output@routine\xp{\saved@output@routine}%
  555.     \let\CurrentShipout\saved@shipout
  556.     \global\hsize\saved@hsize \global\mark@items\saved@mark@items
  557.     \global\cs@counter@name{Page}\saved@pageno
  558.     \unvbox\saved@page@box
  559.     \Tmessage[out]{Resume output}%
  560.     }
  561.  
  562. %%%%%%%%%%%%%%%% Marks
  563. %%%%
  564. \NewTrace:mark
  565. \def\FirstPlaced:#1 
  566.    {\Tmessage[mark]{First Placed #1 from \firstmark}%
  567.     \xp\get@placed\xp{\firstmark}{#1}}
  568. \def\PreviousPlaced:#1
  569.    {\Tmessage[mark]{Previous Placed #1 from \topmark}%
  570.     \xp\get@placed\xp{\topmark}{#1}}
  571. \def\LastPlaced:#1
  572.    {\Tmessage[mark]{Last Placed #1 from \botmark}%
  573.     \xp\get@placed\xp{\botmark}{#1}}
  574. \def\get@placed#1#2{%
  575.     \get@@placed{#2}#1{SM}{}$}% SM: StopMarker
  576. \def\get@@placed#1#2#3{\if\EqualStringX{#2}{SM}\xp\take@to@dollar
  577.     \else\if\EqualStringX{#1}{#2}%
  578.               \maybe@uppercase{#3}\xp\xp\xp\take@to@dollar
  579.          \else\xp\xp\xp\get@@placed\fi
  580.     \fi{#1}}
  581. \ifini{\newtoks\mark@items}
  582.       % \newtoks\mark@toks % is this one used?
  583.  
  584. \newif\ifhas@marks
  585. \add@generic@default{\has@marksno}
  586.     % only yes in heading and output routine.
  587.     % it seems that you can have page breaks at marks...
  588. \@GenericOption{nomarks}{\has@marksno}
  589. \def\add@mark@item#1{\csarg\newtoks{mark@toks@#1}%
  590.     \Tmessage[mark]{Adding mark item #1}%
  591.     \global\mark@items\xp{\the\mark@items{#1}}}
  592. \def\refresh@mark@item#1#2{\csarg\global{mark@toks@#1}{#2}}
  593. \def\get@mark@items#1{\if\EqualStringX{#1}{SM}%
  594.     \else{#1}{\csarg\the{mark@toks@#1}}\xp\get@mark@items
  595.     \fi}
  596. \def\place@mark{\mark{\xp\get@mark@items\the\mark@items{SM}}}
  597.  
  598. % this one should be defined in document.tex
  599. \add@mark@item{first@page}
  600.  
  601. % Page wide rule
  602.  
  603. \@PageGridOption{pagerule}{
  604.     \@add@toks{\hrule width\page@width\relax\nobreak}}
  605.  
  606. % Set default otr@settings and otr@conditions
  607. \set@otr@stuff
  608.  
  609. \endinput
  610.  
  611. 92/10/24 raggedbottom in progress
  612. 92/11/04 splittopskip made equal to topskip
  613. 92/11/14 messed with otr@xyz token lists
  614. 92/11/15 warning on underfull text column;
  615.            ragged bottom still not working properly
  616. 93/01/17 box \WholePage, new definition of \CurrentShipout
  617.  
  618.  
  619. %%%%%%%%%%%%%%%%%%%%%% Old Stuff; maybe useful, maybe not
  620.  
  621. \newskip\@topS \newskip\@botS
  622. {\noeol
  623. \othercr
  624. \gdef\topillustratie{\bgroup\othercr \@topill}
  625. \gdef\@topill:#1=#2^^M{\edef\cs@e{\gdef\CSname{@topS#1}{#2}}
  626.     \cs@e \global\advance\@topS #2\egroup}
  627. \gdef\botillustratie{\bgroup\othercr \@botill}
  628. \gdef\@botill:#1=#2^^M{\edef\cs@e{\gdef\CSname{@botS#1}{#2}}
  629.     \cs@e \global\advance\@botS #2\egroup}}
  630.  
  631. \def\@wisill{\global\@topS\z@ \global\@botS\z@
  632.     \csarg\gdef{@topS1}{\z@}\csarg\gdef{@botS1}{\z@}
  633.     \csarg\gdef{@topS2}{\z@}\csarg\gdef{@botS2}{\z@}
  634.     \csarg\gdef{@topS3}{\z@}\csarg\gdef{@botS3}{\z@}
  635.     }
  636. \@wisill
  637.  
  638. \newtoks\@stramienlijst
  639. \def\invoerpad{}
  640. \def\opmaak: #1\par{\@stramienlijst={}
  641.     \def\cs@a##1 {\eqstring{##1}{klaar}{}%
  642.        {\append@to@list{@stramienlijst}{\@probeerstramien ##1;}
  643.         \cs@a}}
  644.     \cs@a #1klaar }%% let op de significante spaties!!
  645.     %% en de spatie achter het laatste stramien komt van de ^^M
  646. \def\invoer: #1 {
  647.     \def\@probeerstramien ##1;{\csn ##1\ecs 
  648.         \message{Ik probeer het met opmaak: ##1}
  649.         \@installeertellers{##1}
  650.         \input \invoerpad#1.tex
  651.         \vfill\eject
  652.         \@bewaartellers{##1}
  653.         }
  654.     \the\@stramienlijst}
  655.  
  656. %% uitloop van vorige output routine
  657. % iftempf: als pagina geen uitloop gebruikt, direct eventuele
  658. %          uitloop leeg gooien.
  659. % laatste pagina: tempboxa <- vbox{unvcopy255}
  660. % er wordt een pagina uitgeworpen:
  661. %    - 255 is void: invoer is op, dus uitlopen 
  662. %                   als dit de laatste pagina was
  663. %    - 255 non-void: er is iets terug te werpen; dit was kennelijk niet
  664. %                   de laatste pagina, dus geen uitloop.
  665.  
  666. \newbox\@uitloop \newbox\@tempuitloop \newif\ifisereenuitloop
  667.     \Tmessage[out]{Aangetroffen uitloop: \the\ht\@uitloop+\the\dp\@uitloop}
  668.  
  669. %-- uitloop
  670. % mag alleen in kop of voet voorkomen.
  671. \setbox\@tempuitloop=
  672.         \vbox{\ifvoid\topins\else\unvcopy\topins\fi
  673.               \unvcopy\@cclv\kern\z@}
  674. \setbox\@tempuitloop=\hbox{}
  675. \@PageGridOption{uitloop}{\tempfyes 
  676.     \@add@toks{\Tmessage[out]{Uitloop wordt verwerkt.}% 
  677.           \copy\@uitloop 
  678.           }}
  679.  
  680.           \iftempd
  681.               \iftempc \Tmessage[out]{Eerste pagina, derhalve:}
  682.                        \@loopnietuit \else \@loopuit \fi
  683.           \else \Tmessage[out]{Niet de laatste pagina, derhalve:}
  684.                 \@loopnietuit \fi
  685.  
  686.           \iftempf \else \nxp\@uitloopwegwerpen \fi %geheugenbesparing.
  687.  
  688. \def\@loopuit{\global\isereenuitloopyes 
  689.     \global\setbox\@uitloop=\box\@tempuitloop
  690.     \Tmessage[out]{Uitloop: \the\ht\@uitloop+\the\dp\@uitloop}}
  691. \def\@loopnietuit{\global\isereenuitloopno \@uitloopwegwerpen}
  692. \def\@uitloopwegwerpen{
  693.     \Tmessage[out]{Uitloop weggegooid: \the\ht\@uitloop+\the\dp\@uitloop}
  694.     \global\setbox\@uitloop=\hbox{}}
  695.  
  696. %-- veld %% is deze nog nodig nu we 'tekstblok' generisch hebben?
  697. \@PageGridOption{veld}{
  698.     \eqstring{#1}{stop}%
  699.          {\@add@toks{\egroup}}%
  700.          {\@add@toks{\vtop\bgroup\kern0cm}
  701.           \eqstring{#1}{uitvullen}{}%
  702.                    {\@add@toks{\hsize=\w@w{#1}}
  703.                     \iftempc\advance\text@width-\w@w{#1}\fi}
  704.          }}
  705. %-- parallel Nog eens goed over nadenken.
  706. \@PageGridOption{parallel}{
  707.     \eqstring{#1}{stop}%
  708.          {\@add@toks{\vfil\egroup\egroup}}%
  709.          {\@add@toks{\vtop\bgroup\kern0cm
  710.                 \vbox to \vsize\bgroup}% dit is fout.
  711.           \eqstring{#1}{uitvullen}{}%
  712.                 {\iftempc\advance\text@width-\w@w{#1}\relax\fi
  713.                  \@add@toks{\hsize=\w@w{#1}}}
  714.           }}
  715. %-- kolommenbalanceren
  716. % heeft alleen zin voor meerkoloms uitvoer,
  717. % werkt alleen op laatste pagina
  718. \@PageGridOption{kolommenbalanceren}{
  719.     \eqstring{#1}{}{\tempgyes}{\csn tempg#1\ecs}}
  720.  
  721.